package com.tuxing.draa_data.pojo.center;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;

import com.tuxing.draa_data.pojo.DraaTemporaryBook;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 *
 * </p>
 *
 * @author yuanshihang
 * @since 2021-12-06
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("new_dc_book")
public class NewDcBook implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId("TITLE_ID")
    private Long titleId;

    /**
     * 库id
     */
    @TableField("COLLECTION_ID")
    private Long collectionId;

    /**
     * 包id
     */
    @TableField("PACKAGE_ID")
    private Long packageId;

    /**
     * 图书元数据记录号
     */
    @TableField("BOOK_RECORD_ID")
    private Long bookRecordId;

    /**
     * 年份
     */
    @TableField("YEAR")
    private Integer year;

    /**
     * 覆盖范围开始时间
     */
    @TableField("SCOPE_BEGIN")
    private String scopeBegin;

    /**
     * 覆盖范围结束时间
     */
    @TableField("SCOPE_END")
    private String scopeEnd;

    /**
     * 时间覆盖范围
     */
    @TableField("TIME_SCOPE")
    private String timeScope;

    /**
     * URL
     */
    @TableField("URL")
    private String url;

    /**
     * 创建人
     */
    @TableField("CREATE_BY")
    private Integer createBy;

    /**
     * 创建时间
     */
    @TableField("CREATE_DATE")
    private LocalDateTime createDate;

    /**
     * 更新人
     */
    @TableField("UPDATE_BY")
    private Integer updateBy;

    /**
     * 更新时间
     */
    @TableField("UPDATE_DATE")
    private LocalDateTime updateDate;

    @TableField("DATA_TYPE")
    private Integer dataType;

    public void createByCrc(Long collectionId, Long packageId, Long bookRecordId, Integer year, String url, Integer dataType) {
        this.collectionId = collectionId;
        this.packageId = packageId;
        this.bookRecordId = bookRecordId;
        this.year = year;
        this.url = url;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
        this.dataType = dataType;
    }

    public void create(Long bookRecordId, Integer dataType, NewDcPackage newDcPackage, Integer year, DraaTemporaryBook temporaryBook) {
        this.collectionId = newDcPackage.getCollectionId();
        this.packageId = newDcPackage.getPackageId();
        this.bookRecordId = bookRecordId;
        this.year = year;
        this.scopeBegin = temporaryBook.getRangeStart();
        this.scopeEnd = temporaryBook.getRangeEnd();
        this.timeScope = temporaryBook.getIncludeRange();
        this.url = temporaryBook.getCompanyUrl();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
        this.dataType = dataType;
    }

    public void createByBegell(Long collectionId,Long packageId, Long bookRecordId, Integer year,Integer dataType,String url){
        this.collectionId = collectionId;
        this.packageId = packageId;
        this.bookRecordId = bookRecordId;
        this.year = year;
        this.dataType = dataType;
        this.url = url;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByIet(Long collectionId,Long packageId, Long bookRecordId, Integer year,Integer dataType,String url){
        this.collectionId = collectionId;
        this.packageId = packageId;
        this.bookRecordId = bookRecordId;
        this.year = year;
        this.dataType = dataType;
        this.url = url;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByIop(Long collectionId,Long packageId, Long bookRecordId, Integer year,Integer dataType,String url){
        this.collectionId = collectionId;
        this.packageId = packageId;
        this.bookRecordId = bookRecordId;
        this.year = year;
        this.dataType = dataType;
        this.url = url;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByRsc(Long collectionId,Long packageId, Long bookRecordId, Integer year,Integer dataType,String url){
        this.collectionId = collectionId;
        this.packageId = packageId;
        this.bookRecordId = bookRecordId;
        this.year = year;
        this.dataType = dataType;
        this.url = url;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByAiaa(Long collectionId,Long packageId, Long bookRecordId, Integer year,Integer dataType,String url){
        this.collectionId = collectionId;
        this.packageId = packageId;
        this.bookRecordId = bookRecordId;
        this.year = year;
        this.dataType = dataType;
        this.url = url;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }
}
